#!/bin/bash

scripts=( hrms auth site catalogue public_services worktime external )
apps=( chowa hrms catalogue pubservices external legacy )

# First step: create database
mysql --user=$1 --password=$2 < ./migration/creation.sql

# Second step: setup app's tables
for app in ${apps[@]}
do
	bash -c "cd ../chowa ; ./setupapp.sh $app"
done

# Third step: transfer old tables to chowa database
./migration.py $1 $2

# Last step: run migration scripts
for script in ${scripts[@]}
do
	mysql --user=$1 --password=$2 < ./migration/$script.sql
done

